<?php
include('include/config.inc.php');
if(!isset($_SESSION['s_activId'.$cfgPack])
  || (isset($_SESSION['s_userType'.$cfgPack]) && isset($cfgFileNames['complainservice'][$_SESSION['s_userType'.$cfgPack]]) 
      && $cfgFileNames['complainservice'][$_SESSION['s_userType'.$cfgPack]] == 0))
{
  $_SESSION['s_urlRedirectDir'] = $_SERVER['REQUEST_URI'];
  header("Location:checkLogin.php");
}
else
{
  $technicianIdDetailArray = array();
  $editArray['userName'] = ""; 
  $editArray['firstName'] = ""; 
	$editArray['lastName']  = ""; 
  $editArray['address']   = "";  
  $editArray['city']      = "";  
  $editArray['mobile1']   = "";  
  $editArray['mobile2']   = "";  
  $editArray['phone']     = "";  
  $editArray['email']     = "";  
  $editArray['image']     = ""; 
  $isEdit = 0;
  $userDetailArray  = array();
  $branchArray      = array();
  $selectedval      = "";
  $userName         = "";
  $password         = "";
  $userType         = "";
  $branchArray      = "";
  $userId           = isset($_REQUEST['userId']) ? $_REQUEST['userId'] : 0;
  $userLastInsertId = 0;
  $j                = "";  
  $userType         = isset($_REQUEST['userType']) ? $_REQUEST['userType'] : 0;
  $technicianName   = "";
  
	$selectTechnician = "SELECT technician.technicianId,technician.userType,technician.firstName,technician.lastName,
                              technician.address,technician.city,technician.mobile1,technician.mobile2,
                              technician.phone,technician.email,technician.image,user.userName
                         FROM technician
                         LEFT JOIN user ON technician.userId = user.userId
                        WHERE technician.status = 'A'";
  if($userType)
  {
  	$selectTechnician .= " AND technician.userType ='".$userType."'";
  }
  $selectTechnician .= " ORDER BY technician.firstName";
  $selectTechnicianResult = mysql_query($selectTechnician);
  $i = 0;
  while($techRow = mysql_fetch_array($selectTechnicianResult))
  {    
    if($techRow['userType'] == 'None')
    {
      $technicianIdDetailArray[$i]['userName'] = "";
      $technicianIdDetailArray[$i]['userType'] = "";
    }
    else
    {
      $technicianIdDetailArray[$i]['userName']        = $techRow['userName'];
      $technicianIdDetailArray[$i]['userType']        = $techRow['userType'];
    }                                                
    $technicianIdDetailArray[$i]['technicianId']    = $techRow['technicianId'];
    $technicianIdDetailArray[$i]['technicianName']  = $techRow['firstName']." ".$techRow['lastName'];
    $technicianIdDetailArray[$i]['address']         = $techRow['address'];
    $technicianIdDetailArray[$i]['city']            = $techRow['city'];
    $technicianIdDetailArray[$i]['mobile1']         = $techRow['mobile1'];
    $technicianIdDetailArray[$i]['mobile2']         = $techRow['mobile2'];
    $technicianIdDetailArray[$i]['phone']           = $techRow['phone'];
    $technicianIdDetailArray[$i]['email']           = $techRow['email'];
    $technicianIdDetailArray[$i]['image']           = $techRow['image'];
    $i++;
}


  include("./bottom.php");
  $smarty->assign("userId",$userId);
  $smarty->assign("userName",$userName);
  $smarty->assign("password",$password);
  $smarty->assign("userType",$userType);
  $smarty->assign("branchArray",$branchArray);
  $smarty->assign("userDetailArray",$userDetailArray);
  $smarty->assign("technicianName",$technicianName);
  $smarty->assign("technicianIdDetailArray",$technicianIdDetailArray);
  $smarty->assign("isEdit",$isEdit);
  $smarty->assign("editArray",$editArray);
  $smarty->assign("selectedval",$selectedval);
  $smarty->display("employeeAj.tpl");
}
?>